/* eslint-disable react/jsx-no-duplicate-props */
import React, { Component } from 'react'
import { Form, Input, Button, Select, message } from 'antd';
import { connect } from "react-redux";
import { removeEmptyField } from '../../../compoent/emptyFild';

const { Option } = Select;

class AddInfo extends Component {
    state = {

    };

    onFinish = (values) => {


            if (values) {
                values.page = 1
                values.size = 10
                const newValues = removeEmptyField(values)
                this.props.addOfflineMsg(newValues).then(res => {
                    this.props.offlineMsgList({ page: 1, size: 10 })
                })
            }
            this.props.handleCancel()


    };

    onFinishFailed = (errorInfo) => {

    };
    render() {

        return (
            <div>
                <Form
                    name="basic"
                    labelCol={{ span: 6 }}
                    wrapperCol={{ span: 14 }}
                    initialValues={{ remember: true }}
                    onFinish={this.onFinish}
                    onFinishFailed={this.onFinishFailed}
                    autoComplete="off"


                >
                    <Form.Item
                        label="标题："
                        name="title"
                        rules={[{required: true, message: '请输入标题!'}]}
                    >
                        <Input/>
                    </Form.Item>

                    <Form.Item
                        label="内容:"
                        name="body"
                        rules={[{required: true, message: '请输入内容!'}]}
                    >
                        <Input.TextArea />
                    </Form.Item>


                    <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                        <Button type="primary" htmlType="submit">
                            确认
                        </Button>
                        <Button type="primary" htmlType="reset" style={{ marginLeft: 30 }}>
                            重置
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        )
    }
}

const mapState = state => ({
    ...state.systemInfo

});

const mapDispatch = dispatch => ({
    ...dispatch.systemInfo
})

export default connect(mapState, mapDispatch)(AddInfo);